/**
 * Created by Administrator on 2017/3/31.
 */
$(function(){
    //搜索栏中搜索条件选择
    var indextype =[
        {"value":1,"text":"全文"},
        {"value":2,"text":"职位"},
        {"value":3,"text":"公司"}
    ];
    $("#keyword_type").select({
        optionData:indextype,
        css:'indexOptions',
        offset:Array(0,1),
        callback:function(){
            //下拉框展开选项点击事件
            $('.indexOptions ul').on('click','li',function(){
                $('.logoAndSearch .searchCont .select i').removeClass('active');
            });
        }
    });

    //筛选栏中收起按钮
    $('.filter .retract').click(function(){
        $('.filter>ul>li:not(.location)').toggleClass('hide');
    });

    //应届生
    $("#graduate").click(function(){
        boxoption(this,work_year_url,'work_year','9');
    });
    //急聘
    $("#anxious").click(function(){
        boxoption(this,anxious_url,'anxious','1');
    });
    //名企
    $("#brandCompany").click(function(){
        boxoption(this,brandcompany_url,'brandcompany','1');
    });

    //工作年限
    option_work_year.unshift({"text": "工作年限不限", "value": ''});
    work_year = $("#work_year").select({
        optionData:option_work_year,//菜单选项数据
        callback:function(val,text){
            var exl="?";
            if(work_year_url.indexOf("?") > 0 ){
                exl='&';
            }
            location.href=work_year_url+exl+'work_year='+val;
        }
    });

    //学历要求
    option_education.unshift({"text": "学历不限", "value": ''});
    education = $("#education ").select({
        optionData:option_education,//菜单选项数据
        callback:function(val,text){
            var exl="?";
            if(education_url.indexOf("?") > 0 ){
                exl='&';
            }
            location.href=education_url+exl+'education='+val;
        }//选择后的动作
    });
});


//应届生、急聘、名企点击后执行操作
function boxoption(othis,url,name,val){
    var exl="?";
    if(url.indexOf("?") > 0 ){
        exl='&';
    }

    if($(othis).attr('checked')=='checked'){
        location.href=url+exl+name+'='+val;
    }else{
        location.href=url+exl;
    }
}


